﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using Kobets.Automation.Chimera.Common;
using Kobets.Automation.Chimera.Common.Contracts;
using Kobets.Automation.Chimera.Common.Models;

namespace Kobets.Automation.Chimera.Agent
{
    [ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.Single)]
    public class AgentContract : IAgentContract
    {
        public Enums.AgentStatus GetStatus()
        {
            return ChimeraAgent.Agent.Status;
        }

        public Common.Agent GetSdi()
        {
            return ChimeraAgent.Agent;
        }

        public void RunSteps(IEnumerable<Step> steps)
        {
            if (steps == null) throw new ArgumentNullException("steps");
            ChimeraAgent.RunSteps(steps);
        }

        public void StopExecution()
        {
            ChimeraAgent.StopExecution();
        }

        public void Restart()
        {
            ChimeraAgent.Restart();
        }

        public Step GetCurrentlyRunningStep()
        {
            return ChimeraAgent.CurrentStep;
        }

        public void SetController(string controllerName)
        {
            if (controllerName == null) throw new ArgumentNullException("controllerName");
            ChimeraAgent.Agent.Controller = controllerName;
        }
    }
}
